package com.ds.extend.importAware;

import java.util.Map;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportAware;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.stereotype.Component;

@Configuration
public class ImportAwareTest implements ImportAware {


    private int maxConnections;


    @Override
    public void setImportMetadata(AnnotationMetadata annotationMetadata) {
        Map<String, Object> attributesMap = annotationMetadata.getAnnotationAttributes(EnableMyDb.class.getName());
        AnnotationAttributes attrs = AnnotationAttributes.fromMap(attributesMap);
        this.maxConnections = attrs.getNumber("maxConnections");
        System.out.println(this.maxConnections);
    }


    public void store(){
        System.out.println(this.maxConnections);
    }

}
